package com.kingdee.pda.ui.pick_goods;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kingdee.pda.R;

import java.util.List;

/**
 * @author：dlj
 * @data：2021/9/16 15:10
 * @des：
 */
public class PickGoodListAdapter extends BaseQuickAdapter<PickOrderBean.SkuBean, BaseViewHolder> {

    private Context context;
    private int opinionPosition = -1;

    public void setOpinionPosition(int opinionPosition) {
        this.opinionPosition = opinionPosition;
    }

    public PickGoodListAdapter(Context context, List<PickOrderBean.SkuBean> beans) {
        super(R.layout.item_pickgoods_list, beans);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder viewHolder, PickOrderBean.SkuBean item) {
        viewHolder.setText(R.id.tv_skuCode, "SKU编码: " + item.getSkuCode())
            .setText(R.id.tv_locationCode, "拣选仓位: " + item.getLocationCode())
            .setText(R.id.btn_qty, "已拣选/总应拣数: " + item.getPickedQty() + "/" + item.getPickQty())
            .setText(R.id.current_qty, "本次拣选拣数: " + item.getCurrentQty());


        if (opinionPosition != -1 && opinionPosition == viewHolder.getLayoutPosition()) {
            viewHolder.setBackgroundColor(R.id.item, context.getResources().getColor(R.color.color_item_bg));
        } else {
            viewHolder.setBackgroundColor(R.id.item, context.getResources().getColor(R.color.color_ffffff));
        }

//        if (item.getPickedQty() == item.getPickQty()) {
//            viewHolder.setBackgroundRes(R.id.btn_qty, R.drawable.shape_switch_green_track);
//        } else {
//            viewHolder.setBackgroundRes(R.id.btn_qty, R.drawable.shape_switch_grey_track);
//        }
    }
}
